from api.reg import RegAPI
import random


# 创建测试类
class TestReg:
    # 初始化
    def setup_class(self):
        # 创建RegAPI对象
        self.reg = RegAPI()
    # 获取图片验证码（随机小数）
    def test01_get_img_code(self):
        # 获取图片验证码
        response = self.reg.get_img_code(r="0."+str(random.randint(1, 1000)))
        # print(response.status_code)
        assert response.status_code == 200

    # 获取短信验证码
    def test02_get_sms_code(self):
        test_data = {
            "phone": "13834282302",
            "imgVerifyCode": "8888",
            "type": "reg"
        }
        response = self.reg.get_sms_code(test_data=test_data)
        # print(response.json())
        assert response.status_code == 200
        assert response.json().get("status") == 200
        assert "成功" in response.text

    def test03_reg(self):
        pass